function [call, put, putcallparity] = TestPutCallParity()
% Checks if the put-call parity holds for the European call and put options.

priceZero   = 100;          % the initial stock price
volatility  = 0.2;          % volatility of the stock
N           = 10;           % number of steps to use in the tree
strikePrice = 99;           % the strike of the options
interestRate= 0.06;         % the interest rate used
style       = 'european';   % the style of the option, the put-call parity 
                            % only holds for an european option

%Calculating the underlying price of the stock.
stockTree = InitStockTree(priceZero, volatility, N);

% Calculating a call and a put option.
[call, deltahedge, early,earlybetter] = InitialOptionTree(priceZero, volatility, N, ...
	strikePrice, interestRate, 'call', style);
[put, deltahedge, early,earlybetter] = InitialOptionTree(priceZero, volatility, N, ...
	strikePrice, interestRate, 'put', style);


% Checking if the results satisfies the put-call parity relationship.
putcallparity = zeros(N,N);
for j = 1 : N
    for i = 1 : j
    putcallparity(i, j) = (abs(call(i, j) + strikePrice * ...
		exp(-interestRate * (N - j) / N) - (put(i, j) + stockTree(i, j)))) < 0.000001;
    end
end
